<?php
/**
 * 
 *
 * @copyright	Copyright 2009-2010   深圳市饭后科技有限公司
 * @license	LGPL (http://www.gnu.org/licenses/lgpl.html)
 * @author	XinHui Wang <wangxinhui@fanhougame.com
 * @package	生成配置文件
 * @version	
 * @link		http://fanhougame.com/
 */
?>
<?php require_once 'header.php';?>
<script type="text/javascript" src="js/jquery.check_expression.js" ></script>
<link rel='stylesheet' href='js/jquery.check_expression.css' type='text/css' media='screen' />
<form action="<?php echo $action ?>" method="post">
  <table align="center" class="table-6">
    <caption>生成配置文件</caption>
    <tbody><tr>
      <th class="w-p20">配置项</th>
      <th class="a-left">值</th>
    </tr>
    <tr>
      <th>所在网站目录</th>
      <td><input type="text" class="text-3" value="<?php echo HZHIHU_ROOT; ?>" id="webRoot" name="webRoot"> 
      <font color="red">*</font>
   </td>
    </tr>
    <tr>
      <th>URL方式</th>
      <td><select class="select-3" id="requestType" name="requestType">
<option selected="selected" value="0" <?php if(!$config->htaccess) echo "selected='selected'"; ?>>普通方式</option>
</select>  
<font color="red">*</font>
</td>
    </tr>
    <tr>
      <th>默认语言</th>
      <td><select class="select-3" id="defaultLang" name="defaultLang">
<option selected="selected" value="cn" <?php if($config->language=='cn') echo 'selected="selected"'; ?>>中文简体</option>
</select> 
<font color="red">*</font>
</td>
    </tr>
    <tr>
      <th>MVC目录</th>
      <td><input type="text" class="text-3" value="catalog" id="mvcdir" name="mvcdir">
      <font color="red">*</font>
</td>
    </tr>	
    <tr>
      <th>入口文件</th>
      <td><input type="text" class="text-3" value="index.php" id="inFile" name="inFile">
      <font color="red">*</font>
</td>
    </tr>	    
    <tr>
      <th>数据库服务器</th>
      <td><input type="text" class="text-3" value="<?php echo  $config->db[$config->db_types]['db_host']?>" id="dbHost" name="dbHost">
      <font color="red">*</font>
如果localhost无法访问，尝试使用127.0.0.1</td>
    </tr>
    <tr>
      <th>数据库编码</th>
      <td><input type="text" class="text-3" value="<?php echo  $config->db[$config->db_types]['db_charset']?>" id="dbCharset" name="dbCharset">
      <font color="red">*</font>
	</td>
    </tr>	
    <tr>
      <th>服务器端口</th>
      <td><input type="text" class="text-3" value="<?php echo  $config->db[$config->db_types]['db_port']?>" id="dbPort" name="dbPort">
      <font color="red">*</font> 
</td>
    </tr>
    <tr>
      <th>数据库用户名</th>
      <td><input type="text" class="text-3" value="<?php echo  $config->db[$config->db_types]['db_username']?>" id="dbUser" name="dbUser">
      <font color="red">*</font> 
</td>
    </tr>
    <tr>
      <th>数据库密码</th>
      <td><input type="text" class="text-3" value="<?php echo  $config->db[$config->db_types]['db_password']?>" id="dbPassword" name="dbPassword">
      <font color="red">*</font> 
</td>
    </tr>
    <tr>
      <th>使用的库</th>
      <td><input type="text" class="text-3" value="<?php echo  $config->db[$config->db_types]['db_name']?>" id="dbName" name="dbName">
      <font color="red">*</font> 
	  <font id="sql_error">&nbsp;</font>
</td>
    </tr>
    <tr>
      <th>建表使用的前缀</th>
      <td><input type="text" class="text-3" value="<?php echo  $config->db[$config->db_types]['db_prefix']?>" id="dbPrefix" name="dbPrefix"> 
<span><input type="checkbox" value="0" name="clearDB" id="clearDB"> <label>清空现有数据</label></span>
</td>
    </tr>
    <tr>
      <td class="a-center" colspan="2"> <input type="submit" class="button-s" value="保存" id="submit"><input type="reset" class="button-s" value="重置"  /></td>
    </tr>
  </tbody></table>
</form>
<script type="text/javascript">
$(document).ready(function(){
	 $("#webRoot").expression({
			expression:'empty',
			msg:'所在网站目录不能为空'
		})	
	$("#mvcdir").expression({
			expression:'empty||special',
			msg:'MVC目录不能为空||不能有特殊符号'		
	})
	
	$("#inFile").expression({
			expression:'empty',
			msg:'入口文件不能为空'		
	})
	
	$("#dbCharset").expression({
			expression:'empty',
			msg:'不能为空'		
	})	
	
	$("#dbHost").expression({
			expression:'empty',
			msg:'不能为空',
			ajax_url:'<?php echo $ajax_checksql ?>',
			ajax_data:'{"dbHost":$("#dbHost").val(),"dbPort":$("#dbPort").val(),"dbUser":$("#dbUser").val(),"dbPassword":$("#dbPassword").val(),"dbName":$("#dbName").val()}'						
	})	
	
	$("#dbPort").expression({
			expression:'empty',
			msg:'不能为空',
			ajax_url:'<?php echo $ajax_checksql ?>',
			ajax_data:'{"dbHost":$("#dbHost").val(),"dbPort":$("#dbPort").val(),"dbUser":$("#dbUser").val(),"dbPassword":$("#dbPassword").val(),"dbName":$("#dbName").val()}'						
	})
	
	$("#dbPassword").expression({
			expression:'ck_password',
			msg:'xxx',
			ajax_url:'<?php echo $ajax_checksql ?>',
			ajax_data:'{"dbHost":$("#dbHost").val(),"dbPort":$("#dbPort").val(),"dbUser":$("#dbUser").val(),"dbPassword":$("#dbPassword").val(),"dbName":$("#dbName").val()}'	
	})
	
	$("#dbUser").expression({
			expression:'empty',
			msg:'不能为空',
			ajax_url:'<?php echo $ajax_checksql ?>',
			ajax_data:'{"dbHost":$("#dbHost").val(),"dbPort":$("#dbPort").val(),"dbUser":$("#dbUser").val(),"dbPassword":$("#dbPassword").val(),"dbName":$("#dbName").val()}'						
	})	
	
	$("#dbName").expression({
			expression:'empty',
			msg:'不能为空',
			ajax_url:'<?php echo $ajax_checksql ?>',
			ajax_data:'{"dbHost":$("#dbHost").val(),"dbPort":$("#dbPort").val(),"dbUser":$("#dbUser").val(),"dbPassword":$("#dbPassword").val(),"dbName":$("#dbName").val()}'				
	})		
	
})

function ck_password()
{
return true;
}
</script>
</body>
</html>